//
//  SearchHistoryManager.m
//  ShanMei
//
//  Created by huazi on 15/7/3.
//  Copyright (c) 2015年 huazi. All rights reserved.
//

#import "SearchHistoryManager.h"

@implementation SearchHistoryManager
+(SearchHistoryManager *)shareSearchHistoryManager { static SearchHistoryManager *_searchHistoryManager =nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _searchHistoryManager =[[SearchHistoryManager alloc] init];
    });
    return _searchHistoryManager;
}
- (instancetype)init {
    if (self =[super init]) {
        HZSQLManager *SqlManager =[HZSQLManager shareSQLManager];
        NSString *strCreateTablesearchHistory =@"CREATE TABLE  IF NOT EXISTS searchHistory (searchtext TEXT )";
        [SqlManager execSql:strCreateTablesearchHistory];
    }
    return self;
}
- (void)addSearchHistoryToSearchHistoryTable:(NSString *)searchHistory {
    HZSQLManager *SQLManager =[HZSQLManager shareSQLManager];
    NSString * strDelete =[NSString stringWithFormat:@"DELETE FROM searchHistory WHERE searchtext ='%@' ",searchHistory];
    [SQLManager execSql:strDelete];
    
    NSString *strINSRETINTO =[NSString stringWithFormat:@"INSERT INTO searchHistory (searchtext) VALUES(\"%@\")",searchHistory];
    [SQLManager execSql:strINSRETINTO];
}
- (void)deleteTable {
    HZSQLManager *SQLManager =[HZSQLManager shareSQLManager];
    NSString * strDelete =[NSString stringWithFormat:@"DELETE FROM searchHistory "];
    [SQLManager execSql:strDelete];

}
@end
